package com.king.config;

import com.king.interceptor.OneInterceptor;
import com.king.interceptor.TwoInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * com.king.config
 *
 * @Description: 配置类
 * @Author: kuaipeng
 * @Created: on 2019/12/05
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {

    /**注册拦截器*/
    @Bean
    public OneInterceptor oneInterceptor(){
        return new OneInterceptor();
    }
    @Bean
    public TwoInterceptor TwoInterceptor(){
        return new TwoInterceptor();
    }

    /**添加拦截器到spring mvc拦截器链*/
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(oneInterceptor()).addPathPatterns("/*");
        registry.addInterceptor(TwoInterceptor()).addPathPatterns("/*");
    }
}
